package com.example.demo.auth;

import org.springframework.http.HttpStatus;

public class AuthResult {
    private boolean isVerify;

    private String message;

    private BaseUserInfo userInfo;

    private HttpStatus httpStatus;

    public String getResultJson(){
        return "{\"code\":0,\"message\":\""+this.message+"\"}";
    }
    /**
     * Gets the value of userInfo.
     *
     * @return the value of userInfo
     */
    public BaseUserInfo getUserInfo() {
        return userInfo;
    }

    /**
     * Sets the userInfo.
     *
     * <p>You can use getUserInfo() to get the value of userInfo</p>
     *
     * @param userInfo userInfo
     */
    public void setUserInfo(BaseUserInfo userInfo) {
        this.userInfo = userInfo;
    }

    public boolean isVerify() {
        return isVerify;
    }

    /**
     * Sets the isVerify.
     *
     * <p>You can use getVerify() to get the value of isVerify</p>
     *
     * @param verify isVerify
     */
    public void setVerify(boolean verify) {
        isVerify = verify;
    }

    /**
     * Gets the value of message.
     *
     * @return the value of message
     */
    public String getMessage() {
        return message;
    }

    /**
     * Sets the message.
     *
     * <p>You can use getMessage() to get the value of message</p>
     *
     * @param message message
     */
    public void setMessage(String message) {
        this.message = message;
    }

    /**
     * Gets the value of httpStatus.
     *
     * @return the value of httpStatus
     */
    public HttpStatus getHttpStatus() {
        return httpStatus;
    }

    /**
     * Sets the httpStatus.
     *
     * <p>You can use getHttpStatus() to get the value of httpStatus</p>
     *
     * @param httpStatus httpStatus
     */
    public void setHttpStatus(HttpStatus httpStatus) {
        this.httpStatus = httpStatus;
    }

    public static AuthResult newUnAuthResult(String message){
        AuthResult authResult = new AuthResult();
        authResult.setHttpStatus(HttpStatus.UNAUTHORIZED);

        authResult.setMessage(message==null?"验证未通过":message);
        authResult.setVerify(false);
        return authResult;
    }
}
